# Contributor: Holger Jaekel <holger.jaekel@gmx.de>
# Maintainer:
pkgname=aws-c-compression
pkgver=0.2.17
pkgrel=1
pkgdesc="C99 implementation of huffman encoding/decoding"
url="https://github.com/awslabs/aws-c-compression"
# s390x: aws-c-common
arch="all !s390x"
license="Apache-2.0"
makedepends="
	aws-c-common-dev
	cmake
	samurai
	"
subpackages="$pkgname-dev"
source="$pkgname-$pkgver.tar.gz::https://github.com/awslabs/aws-c-compression/archive/refs/tags/v$pkgver.tar.gz"

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	CFLAGS="$CFLAGS -flto=auto" \
	CXXFLAGS="$CXXFLAGS -flto=auto" \
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=/usr/lib \
		-DBUILD_SHARED_LIBS=True \
		-DCMAKE_BUILD_TYPE=None \
		-DBUILD_TESTING="$(want_check && echo ON || echo OFF)" \
		$CMAKE_CROSSOPTS
	cmake --build build
}

check() {
	ctest --test-dir build --output-on-failure -j${JOBS:-2}
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

dev() {
	default_dev
	amove usr/lib/aws-c-compression
}

sha512sums="
7813ae3d19336a187dd218d22748a09b397aea68f344e44ce0472490babdd7c7a4bb94d586a38d7f0c7d3b6f29502ec9ccf080b020e15fd24891ec1b3cdb4663  aws-c-compression-0.2.17.tar.gz
"
